package com.zjw.zy.coreui.dialog;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.zjw.zy.R;
import com.zjw.zy.base.BaseDialog;
import com.zjw.zy.bean.DailyWeather;
import com.zjw.zy.coreui.view.WeatherSimpleItemView;
import com.zjw.zy.utils.AppUtils;

/**
 * @author ：zhong.jw
 * @date ：Created in 2022/9/29 17:45
 */
public class WeatherDialog extends BaseDialog {

    private static WeatherDialog INSTANCE;

    private DailyWeather data = null;

    public static void showWeather(@NonNull DailyWeather weather) {
        if (INSTANCE == null) {
            synchronized (WeatherDialog.class) {
                if (INSTANCE == null) {
                    INSTANCE = new WeatherDialog(AppUtils.getMainActivity());
                }
            }
        }
        INSTANCE.data = weather;
        INSTANCE.show();
    }

    private WeatherSimpleItemView weatherSimpleItemView;


    protected WeatherDialog(@NonNull Context context) {
        super(context);
    }

    protected WeatherDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected WeatherDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onFindView() {
        weatherSimpleItemView = findViewById(R.id.main_weather_view);
    }

    @Override
    protected void onBindListener() {

    }

    @Override
    protected void onBindValue() {
        if (data != null) {
            weatherSimpleItemView.setWeatherDailyInformation(data);
        }
    }

    @Override
    protected int onLayoutId() {
        return R.layout.dialog_weather_item_detail;
    }
}
